#!/usr/bin/python3
# coding=utf-8
#
# Copyright (C) 2023-2024. Huawei Technologies Co., Ltd. All rights reserved.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# ===============================================================================

import numpy as np
import os

def flip(x, dim):
    """Flip函数：沿着指定维度反转元素的顺序"""
    # 使用numpy的flip函数实现
    return np.flip(x, axis=dim)

def gen_golden_data_simple():
    # 生成输入数据 [N, C, H, W] = [2, 3, 4, 5]
    input_shape = (8, 1, 8, 2048)
    input_data = np.random.uniform(low=-1.0, high=1.0, size=input_shape).astype(np.float32)
    
    dim = 3
    
    # 计算Flip函数
    golden = flip(input_data, dim).astype(np.float32)
    
    # 创建目录
    os.makedirs("input", exist_ok=True)
    os.makedirs("output", exist_ok=True)
    
    # 保存输入和输出
    input_data.tofile("input/input_x.bin")
    golden.tofile("output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()